<!-- 病害派单页面 -->
<template>
	<view class="">
		<dispatch titleName="病害派单" compoType="disease_dispatch" :treeData="copyData" @searchChange="searchChange" @determine="determine"></dispatch>
	</view>
</template>


<script>
	import dispatch from '../common/dispatch.vue'
	import searchCom from "@/components/searchCom.vue"
	import mixins from '@/utils/mixins.js'
	import {
		getPlanLineSectionSiteStateTreeByLike, //树形列表
		inspectLogUpdateState, //更改状态
	} from '@/api/engineeringMaintenance/engineeringMaintenance.js'
	import {
		doSave,
		doGet,
		doCache
	} from '@/utils/offline/index.js'
	export default {
		name:'diseaseDispatch',
		mixins:[mixins],
		components: {
			searchCom,
			dispatch
		},
		data() {
			return {
				treeData: [],
				copyData:[],
				keyword:undefined
			}
		},
		onShow() {
			this.getTreeListData()
		},
		methods: {
			// 获取树形数据
			getTreeListData() {
				getPlanLineSectionSiteStateTreeByLike({
						projectId: uni.getStorageSync('isOwner'),
						projectStates:["zj","zt"],
						type: 'disease_dispatch'
					})
					.then(res => {
						console.log(res)
						if (res.status === 1 && res.success) {
							this.treeData = res.result
							this.copyData = res.result
							console.log(this.treeData, 'treeData')
						}
					})
			},
			/**
			 * 输入框值变化的时候
			 * @param {String} val
			 */
			searchChange(val) {
				// this.keyword = val
				if(!val) {
					this.copyData = this.treeData
				}
			},
			determine(ev) {
				console.log(ev)
				this.copyData = this.mapTree(ev, this.treeData)
			},
		}
	}
</script>

<style lang="scss" scoped>
</style>